package com.gc.controller;

import com.gc.pojo.Article;
import com.gc.pojo.Page;
import com.gc.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

@Controller
public class ArticleController {

    @Autowired
    private ArticleService articleService;

    //如果没有传参 默认page 0 size 2
    @RequestMapping("index")
    public ModelAndView index(@RequestParam(defaultValue = "0") int page, @RequestParam(defaultValue = "2") int size, ModelAndView modelAndView){

        Page<Article> articlePage= articleService.findAll(page,size);
        modelAndView.addObject("data",articlePage);
        modelAndView.setViewName("client/index");
        return  modelAndView;
    }
}
